from pydantic import BaseModel
from typing import List, Optional
from datetime import datetime

class FolderPermissionCreate(BaseModel):
    target_id: int  # 部门ID或用户ID
    can_read: bool = True
    can_write: bool = False
    can_delete: bool = False

class DepartmentPermissionInfo(BaseModel):
    id: int
    department_id: int
    department_name: str
    can_read: bool
    can_write: bool
    can_delete: bool
    created_at: datetime

class UserPermissionInfo(BaseModel):
    id: int
    user_id: int
    username: str
    full_name: str
    can_read: bool
    can_write: bool
    can_delete: bool
    created_at: datetime

class FolderPermissionInfo(BaseModel):
    folder_id: int
    folder_name: str
    department_permissions: List[DepartmentPermissionInfo]
    user_permissions: List[UserPermissionInfo]

class FileShareUpdate(BaseModel):
    share_level: str  # private, department, public, custom

class FileShareInfo(BaseModel):
    file_id: int
    file_name: str
    share_level: str
    owner_name: str

class PermissionCheck(BaseModel):
    can_read: bool
    can_write: bool
    can_delete: bool
    reason: Optional[str] = None